<html>
 <head>
  <link href="./leetcode-problem.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div class="question_difficulty">
   难度：Medium
  </div>
  <div>
   <h1 class="question_title">
    73. Set Matrix Zeroes
   </h1>
   <p>
    Given a
    <em>
     m
    </em>
    x
    <em>
     n
    </em>
    matrix, if an element is 0, set its entire row and column to 0. Do it
    <a href="https://en.wikipedia.org/wiki/In-place_algorithm" target="_blank">
     <strong>
      in-place
     </strong>
    </a>
    .
   </p>
   <p>
    <strong>
     Example 1:
    </strong>
   </p>
   <pre>
<strong>Input:</strong> 
[
&nbsp; [1,1,1],
&nbsp; [1,0,1],
&nbsp; [1,1,1]
]
<strong>Output:</strong> 
[
&nbsp; [1,0,1],
&nbsp; [0,0,0],
&nbsp; [1,0,1]
]
</pre>
   <p>
    <strong>
     Example 2:
    </strong>
   </p>
   <pre>
<strong>Input:</strong> 
[
&nbsp; [0,1,2,0],
&nbsp; [3,4,5,2],
&nbsp; [1,3,1,5]
]
<strong>Output:</strong> 
[
&nbsp; [0,0,0,0],
&nbsp; [0,4,5,0],
&nbsp; [0,3,1,0]
]
</pre>
   <p>
    <strong>
     Follow up:
    </strong>
   </p>
   <ul>
    <li>
     A straight forward solution using O(
     <em>
      m
     </em>
     <em>
      n
     </em>
     ) space is probably a bad idea.
    </li>
    <li>
     A simple improvement uses O(
     <em>
      m
     </em>
     +
     <em>
      n
     </em>
     ) space, but still not the best solution.
    </li>
    <li>
     Could you devise a constant space solution?
    </li>
   </ul>
  </div>
  <div>
   <h1 class="question_title">
    73. 矩阵置零
   </h1>
   <p>
    给定一个&nbsp;
    <em>
     m
    </em>
    x
    <em>
     n
    </em>
    的矩阵，如果一个元素为 0，则将其所在行和列的所有元素都设为 0。请使用
    <strong>
     <a href="http://baike.baidu.com/item/%E5%8E%9F%E5%9C%B0%E7%AE%97%E6%B3%95" target="_blank">
      原地
     </a>
    </strong>
    算法
    <strong>
     。
    </strong>
   </p>
   <p>
    <strong>
     示例&nbsp;1:
    </strong>
   </p>
   <pre><strong>输入:</strong> 
[
&nbsp; [1,1,1],
&nbsp; [1,0,1],
&nbsp; [1,1,1]
]
<strong>输出:</strong> 
[
&nbsp; [1,0,1],
&nbsp; [0,0,0],
&nbsp; [1,0,1]
]
</pre>
   <p>
    <strong>
     示例&nbsp;2:
    </strong>
   </p>
   <pre><strong>输入:</strong> 
[
&nbsp; [0,1,2,0],
&nbsp; [3,4,5,2],
&nbsp; [1,3,1,5]
]
<strong>输出:</strong> 
[
&nbsp; [0,0,0,0],
&nbsp; [0,4,5,0],
&nbsp; [0,3,1,0]
]</pre>
   <p>
    <strong>
     进阶:
    </strong>
   </p>
   <ul>
    <li>
     一个直接的解决方案是使用 &nbsp;O(
     <em>
      m
     </em>
     <em>
      n
     </em>
     )&nbsp;的额外空间，但这并不是一个好的解决方案。
    </li>
    <li>
     一个简单的改进方案是使用 O(
     <em>
      m
     </em>
     &nbsp;+&nbsp;
     <em>
      n
     </em>
     ) 的额外空间，但这仍然不是最好的解决方案。
    </li>
    <li>
     你能想出一个常数空间的解决方案吗？
    </li>
   </ul>
  </div>
 </body>
</html>